﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Data.SqlClient;
using System.IO;

namespace Tamaris
{
    public partial class Main : Form
    {
        public Connexion connexion;
        Boolean responsable_exist = false;
        Boolean parcour_activite = false;
        Boolean parcour_employes = false;
        Boolean parcour_estivant = false;
        Boolean parcour_emplacement = false;
        Boolean parcour_emplacement2 = false;

        public Main()
        {
            InitializeComponent();
        }

        public Main(Connexion c):this()
        {
            connexion = c;
        }

        private void dateTimePicker_fin_ValueChanged(object sender, EventArgs e)
        {
            TimeSpan duree = dateTimePicker_fin.Value - dateTimePicker_debut.Value;
            textBox_duree_sejour.Text = duree.Days.ToString();
        }

        private void textBox_duree_sejour_MouseClick(object sender, MouseEventArgs e)
        {
            textBox_duree_sejour.Text = "";
        }

        private void main_Load(object sender, EventArgs e)
        {
            button_ajouter_employes.Visible = false;

            // TODO: cette ligne de code charge les données dans la table 'dataSet4.TYPE'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
            this.tYPETableAdapter.Fill(this.dataSet4.TYPE);
            // TODO: cette ligne de code charge les données dans la table 'dataSet2.EMPLACEMENT'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
            this.eMPLACEMENTTableAdapter.Fill(this.dataSet2.EMPLACEMENT);
            // TODO: cette ligne de code charge les données dans la table 'dataSet1.TEST_TYPE'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
            this.tEST_TYPETableAdapter.Fill(this.dataSet1.TEST_TYPE);


            if (connexion.Identifiant.Text == "dim")
            {
                this.tabControl.TabPages.Remove(this.tabControl.TabPages["tabPage_gestionaire"]);
            }
        }

        private void listBox_estivant_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void test1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (responsable_exist == false)
            {
                if (textBox_Nom.Text != "" && textBox_Prenom.Text != "" && textBox_Adresse.Text != "" && textBox_Cp.Text != "" && textBox_Ville.Text != "" && textBox_Email.Text != "")
                {
                    listBox_estivant.Items.Add("[Resp] " + textBox_Nom.Text + " " + textBox_Prenom.Text + " " + textBox_Adresse.Text + " " + textBox_Cp.Text + " " + textBox_Ville.Text);
                }
                responsable_exist = true;
            }
        }

        private void ajouterEnTantQuestivantToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String si_enfant = "";
            if (checkBox_enfant.Checked == true)
            {
                si_enfant = "(enfant)";
            }
            if (textBox_Nom.Text != "" && textBox_Prenom.Text != "" && textBox_Adresse.Text != "" && textBox_Cp.Text != "" && textBox_Ville.Text != "" && textBox_Email.Text != "")
            {
                listBox_estivant.Items.Add(textBox_Nom.Text + " " + textBox_Prenom.Text + " " + textBox_Adresse.Text + " " + textBox_Cp.Text + " " + textBox_Ville.Text + " " + "" + si_enfant);
            }

            OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
            con.Open();
            OracleCommand cmd = new OracleCommand("PACK_ESTIVANT.ADD_ESTIVANT", con);
            cmd.CommandType = CommandType.StoredProcedure;

            OracleParameter NOM_P = new OracleParameter("NOM_P", OracleDbType.Varchar2);
            NOM_P.Direction = ParameterDirection.Input;
            NOM_P.Value = textBox_Nom.Text;
            cmd.Parameters.Add(NOM_P);

            OracleParameter PRENOM_P = new OracleParameter("PRENOM_P", OracleDbType.Varchar2);
            PRENOM_P.Direction = ParameterDirection.Input;
            PRENOM_P.Value = textBox_Prenom.Text;
            cmd.Parameters.Add(PRENOM_P);

            OracleParameter ADRESSE_P = new OracleParameter("ADRESSE_P", OracleDbType.Varchar2);
            ADRESSE_P.Direction = ParameterDirection.Input;
            ADRESSE_P.Value = textBox_Adresse.Text;
            cmd.Parameters.Add(ADRESSE_P);

            OracleParameter CP_P = new OracleParameter("CP_P", OracleDbType.Varchar2);
            CP_P.Direction = ParameterDirection.Input;
            CP_P.Value = textBox_Cp.Text;
            cmd.Parameters.Add(CP_P);

            OracleParameter VILLE_P = new OracleParameter("VILLE_P", OracleDbType.Varchar2);
            VILLE_P.Direction = ParameterDirection.Input;
            VILLE_P.Value = textBox_Ville.Text;
            cmd.Parameters.Add(VILLE_P);

            OracleParameter TEL_P = new OracleParameter("TEL_P", OracleDbType.Varchar2);
            TEL_P.Direction = ParameterDirection.Input;
            TEL_P.Value = textBox_Telephone.Text;
            cmd.Parameters.Add(TEL_P);

            OracleParameter PORT_P = new OracleParameter("PORTABLE_P", OracleDbType.Varchar2);
            PORT_P.Direction = ParameterDirection.Input;
            PORT_P.Value = textBox_Portable.Text;
            cmd.Parameters.Add(PORT_P);

            OracleParameter MEL_P = new OracleParameter("MEL_P", OracleDbType.Varchar2);
            MEL_P.Direction = ParameterDirection.Input;
            MEL_P.Value = textBox_Email.Text;
            cmd.Parameters.Add(MEL_P);

            cmd.ExecuteNonQuery();



            OracleCommand cmd2 = new OracleCommand("PACK_ESTIVANT.GET_NUM_ESTIV_BY_NOM", con);
            cmd2.CommandType = CommandType.StoredProcedure;

            OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
            c1.Direction = ParameterDirection.ReturnValue;
            cmd2.Parameters.Add(c1);

            OracleParameter NOM_P2 = new OracleParameter("NOM_P", OracleDbType.Varchar2);
            NOM_P2.Direction = ParameterDirection.Input;
            NOM_P2.Value = textBox_Nom.Text;
            cmd2.Parameters.Add(NOM_P2);

            OracleParameter PRENOM_P2 = new OracleParameter("PRENOM_P", OracleDbType.Varchar2);
            PRENOM_P2.Direction = ParameterDirection.Input;
            PRENOM_P2.Value = textBox_Prenom.Text;
            cmd2.Parameters.Add(PRENOM_P2);

            OracleDataReader reader = cmd2.ExecuteReader();
            int num_estiv = 0;
            while (reader.Read())
            {
                Int32.TryParse(reader["num_estivant"].ToString(), out num_estiv);
            }


            textBox_Email.Text = "";
            textBox_Telephone.Text = "";
            textBox_Portable.Text = "";
            textBox_Ville.Text = "";
            textBox_Cp.Text = "";
            textBox_Adresse.Text = "";
            textBox_Prenom.Text = "";
            textBox_Nom.Text = "";
        }

        private void supprimerLestivantToolStripMenuItem_Click(object sender, EventArgs e)
        {
            listBox_estivant.Items.Remove(listBox_estivant.SelectedItem);
        }

        private void choisirLemplacementToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox_Nom.Text = "";
            textBox_Prenom.Text = "";
            textBox_Adresse.Text = "";
            textBox_Cp.Text = "";
            textBox_Ville.Text = "";
            textBox_Email.Text = "";
            textBox_duree_sejour.Text = "";
            checkBox_enfant.Checked = false;
            responsable_exist = true;

            Map affichage_map = new Map(this);
            affichage_map.Show();
        }

        private void tESTTYPEBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void comboBox_emplacement_TextChanged(object sender, EventArgs e)
        {
            OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
            con.Open();
            OracleCommand cmd = new OracleCommand("GET_PRICE_BY_TYPE", con);
            cmd.CommandType = CommandType.StoredProcedure;


            OracleParameter my_ret = new OracleParameter("my_ret", OracleDbType.Varchar2, 50);
            my_ret.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(my_ret);

            OracleParameter type_p = new OracleParameter("type_p", OracleDbType.Varchar2);
            type_p.Direction = ParameterDirection.Input;
            type_p.Value = comboBox_emplacement.Text;
            cmd.Parameters.Add(type_p);

            cmd.ExecuteNonQuery();
            label_tarif.Text = my_ret.Value.ToString();
            con.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
            con.Open();
            OracleCommand cmd = new OracleCommand("PACK_ESTIVANT.GET_ALL_ESTIVANT", con);
            cmd.CommandType = CommandType.StoredProcedure;

            OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
            c1.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(c1);

            OracleDataReader reader = cmd.ExecuteReader();


            /*string[] sentences = 
            {
                comboBox_nom_estivant.Items(0),
            };

            int i =0;
            while (reader.Read())
            {
                sentences[i] = reader["nom"].ToString();
                i++;
            }

            string sPattern = textBox_recherche.Text;

            foreach (string s in sentences)
            {
                System.Console.Write("{0,24}", s);

                if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    comboBox_nom_estivant.Items.Add(s);
                }
                else
                {
                    System.Console.WriteLine();
                }
            }*/
        }

        private void comboBoxactivites_MouseClick(object sender, MouseEventArgs e)
        {
            if (parcour_activite == false)
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_ACTIVITE.GET_ACTIVITES", con);
                cmd.CommandType = CommandType.StoredProcedure;


                OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
                c1.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(c1);

                OracleDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    comboBox_activites.Items.Add(reader["intitule"].ToString());
                }
                parcour_activite = true;
            }
        }

        private void comboBox6_MouseClick(object sender, MouseEventArgs e)
        {
            if (parcour_employes == false)
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_USER.GET_ALL_USER", con);
                cmd.CommandType = CommandType.StoredProcedure;


                OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
                c1.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(c1);

                OracleDataReader reader = cmd.ExecuteReader();

                comboBox_user_employes.Items.Add("Ajouter");

                while (reader.Read())
                {
                    comboBox_user_employes.Items.Add(reader["grantee"].ToString());
                }
                parcour_employes = true;
            }
        }

        private void comboBox6_TextChanged(object sender, EventArgs e)
        {
            textBox_nom_employes.Text = comboBox_user_employes.Text;
            if (textBox_nom_employes.Text == "Ajouter")
            {
                button_ajouter_employes.Visible = true;
                textBox_nom_employes.Text = "";
            }
        }

        private void comboBox_activites_TextChanged(object sender, EventArgs e)
        {

        }

        private void button_ajouter_employes_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox_mdp_employes.Text != "")
                {
                    OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                    con.Open();
                    OracleCommand cmd = new OracleCommand("PACK_USER.ADD_USER", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (comboBox_role_employes.Text == "AC_EMPLOYE")
                    {
                        OracleParameter login_p = new OracleParameter("login_p", OracleDbType.Varchar2);
                        login_p.Direction = ParameterDirection.Input;
                        login_p.Value = "AC_" + textBox_nom_employes.Text;
                        cmd.Parameters.Add(login_p);
                    }
                    else
                    {
                        OracleParameter login_p = new OracleParameter("login_p", OracleDbType.Varchar2);
                        login_p.Direction = ParameterDirection.Input;
                        login_p.Value = textBox_nom_employes.Text;
                        cmd.Parameters.Add(login_p);
                    }

                    OracleParameter pass_p = new OracleParameter("pass_p", OracleDbType.Varchar2);
                    pass_p.Direction = ParameterDirection.Input;
                    pass_p.Value = textBox_mdp_employes.Text;
                    cmd.Parameters.Add(pass_p);

                    OracleParameter grant_p = new OracleParameter("grant_p", OracleDbType.Varchar2);
                    grant_p.Direction = ParameterDirection.Input;
                    grant_p.Value = comboBox_role_employes.Text;
                    cmd.Parameters.Add(grant_p);

                    cmd.ExecuteNonQuery();
                    con.Close();
                    textBox_controleur.Text += "Ajout d'un employé réussi\n";
                }
            }
            catch(Exception)
            {
                textBox_controleur.Text += "Impossible d'ajouter un employé\n";
            }
        }

        private void button_modifier_employes_Click(object sender, EventArgs e)
        {
            try
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_USER.del_user_pwd", con);
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter USER_P = new OracleParameter("USER_P", OracleDbType.Varchar2);
                USER_P.Direction = ParameterDirection.Input;
                USER_P.Value = comboBox_user_employes.Text;
                cmd.Parameters.Add(USER_P);

                cmd.ExecuteNonQuery();

                OracleCommand cmd2 = new OracleCommand("PACK_USER.add_user", con);
                cmd2.CommandType = CommandType.StoredProcedure;

                OracleParameter LOGIN_P = new OracleParameter("LOGIN_P", OracleDbType.Varchar2);
                LOGIN_P.Direction = ParameterDirection.Input;
                LOGIN_P.Value = textBox_nom_employes.Text;
                cmd2.Parameters.Add(LOGIN_P);

                OracleParameter PASS_P = new OracleParameter("PASS_P", OracleDbType.Varchar2);
                PASS_P.Direction = ParameterDirection.Input;
                PASS_P.Value = textBox_mdp_employes.Text;
                cmd2.Parameters.Add(PASS_P);

                OracleParameter GRANT_P = new OracleParameter("GRANT_P", OracleDbType.Varchar2);
                GRANT_P.Direction = ParameterDirection.Input;
                GRANT_P.Value = comboBox_role_employes.Text;
                cmd2.Parameters.Add(GRANT_P);

                cmd2.ExecuteNonQuery();
                con.Close();
                textBox_controleur.Text += "L'employé à correctement été modifié\n";
            }
            catch
            {
                textBox_controleur.Text += "L'employé n'a pu être modifié\n";
            }
        }

        private void comboBox_nom_estivant_MouseClick(object sender, MouseEventArgs e)
        {
            if (parcour_estivant == false)
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_ESTIVANT.GET_ALL_ESTIVANT", con);
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
                c1.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(c1);

                OracleDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    comboBox_nom_estivant.Items.Add(reader["nom"].ToString() + " " + reader["prenom"].ToString());
                }
                parcour_estivant = true;
            }
       }

        private void comboBox_nom_estivant_SelectedIndexChanged(object sender, EventArgs e)
        {
            OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
            con.Open();
            OracleCommand cmd = new OracleCommand("PACK_ESTIVANT.GET_ESTIVANT_BY_NOM", con);
            cmd.CommandType = CommandType.StoredProcedure;

            OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
            c1.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(c1);

            string values = comboBox_nom_estivant.SelectedItem.ToString();
            string[] nom_prenom = values.Split(' ');
            String mon_nom = nom_prenom[0];
            String mon_prenom = nom_prenom[1];

            OracleParameter NOM_P = new OracleParameter("NOM_P", OracleDbType.Varchar2);
            NOM_P.Direction = ParameterDirection.Input;
            NOM_P.Value = mon_nom;
            cmd.Parameters.Add(NOM_P);

            OracleParameter PRENOM_P = new OracleParameter("PRENOM_P", OracleDbType.Varchar2);
            PRENOM_P.Direction = ParameterDirection.Input;
            PRENOM_P.Value = mon_prenom;
            cmd.Parameters.Add(PRENOM_P);

            OracleDataReader reader = cmd.ExecuteReader();

            comboBox_user_employes.Items.Add("Ajouter");

            while (reader.Read())
            {
                textBox_nom_estivant.Text = reader["nom"].ToString();
                textBox_ville_estivant.Text = reader["ville"].ToString();
                textBox_adresse_estivant.Text = reader["adresse"].ToString();
                textBox_mail_estivant.Text = reader["mail"].ToString();
                textBox_prenom_estivant.Text = reader["prenom"].ToString();
                textBox_cp_estivant.Text = reader["cp"].ToString();
                textBox_portable_estivant.Text = reader["port"].ToString();
                textBox_tel_estivant.Text = reader["tel"].ToString();
            }
        }

        private void button_modifier_estivant_Click(object sender, EventArgs e)
        {
            try
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_ESTIVANT.UPDATE_ESTIVANT", con);
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter NOM_P = new OracleParameter("NOM_P", OracleDbType.Varchar2);
                NOM_P.Direction = ParameterDirection.Input;
                NOM_P.Value = textBox_nom_estivant.Text;
                cmd.Parameters.Add(NOM_P);

                OracleParameter PRENOM_P = new OracleParameter("PRENOM_P", OracleDbType.Varchar2);
                PRENOM_P.Direction = ParameterDirection.Input;
                PRENOM_P.Value = textBox_prenom_estivant.Text;
                cmd.Parameters.Add(PRENOM_P);

                OracleParameter ADRESSE_P = new OracleParameter("ADRESSE_P", OracleDbType.Varchar2);
                ADRESSE_P.Direction = ParameterDirection.Input;
                ADRESSE_P.Value = textBox_adresse_estivant.Text;
                cmd.Parameters.Add(ADRESSE_P);

                OracleParameter CP_P = new OracleParameter("CP_P", OracleDbType.Varchar2);
                CP_P.Direction = ParameterDirection.Input;
                CP_P.Value = textBox_cp_estivant.Text;
                cmd.Parameters.Add(CP_P);

                OracleParameter VILLE_P = new OracleParameter("VILLE_P", OracleDbType.Varchar2);
                VILLE_P.Direction = ParameterDirection.Input;
                VILLE_P.Value = textBox_ville_estivant.Text;
                cmd.Parameters.Add(VILLE_P);

                OracleParameter TEL_P = new OracleParameter("TEL_P", OracleDbType.Varchar2);
                TEL_P.Direction = ParameterDirection.Input;
                TEL_P.Value = textBox_tel_estivant.Text;
                cmd.Parameters.Add(TEL_P);

                OracleParameter PORT_P = new OracleParameter("PORT_P", OracleDbType.Varchar2);
                PORT_P.Direction = ParameterDirection.Input;
                PORT_P.Value = textBox_portable_estivant.Text;
                cmd.Parameters.Add(PORT_P);

                OracleParameter MEL_P = new OracleParameter("MEL_P", OracleDbType.Varchar2);
                MEL_P.Direction = ParameterDirection.Input;
                MEL_P.Value = textBox_mail_estivant.Text;
                cmd.Parameters.Add(MEL_P);

                cmd.ExecuteNonQuery();
                textBox_controleur.Text += "L'estivant n'a pu etre modifié\n";
            }
            catch
            {
                textBox_controleur.Text += "Modification de l'estivant réussi\n";
            }
        }

        private void button_modifier_activite_Click(object sender, EventArgs e)
        {
            try
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_ACTIVITE.UPDATE_ACTIVITY", con);
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter NOM_P = new OracleParameter("INTITULE_P", OracleDbType.Varchar2);
                NOM_P.Direction = ParameterDirection.Input;
                NOM_P.Value = textBox_nv_nom_activites.Text;
                cmd.Parameters.Add(NOM_P);

                OracleParameter PRENOM_P = new OracleParameter("UNITE_P", OracleDbType.Varchar2);
                PRENOM_P.Direction = ParameterDirection.Input;
                PRENOM_P.Value = textBox_unit_temps_activites.Text;
                cmd.Parameters.Add(PRENOM_P);

                OracleParameter ADRESSE_P = new OracleParameter("PRIX_P", OracleDbType.Varchar2);
                ADRESSE_P.Direction = ParameterDirection.Input;
                ADRESSE_P.Value = textBox_prix_activites.Text;
                cmd.Parameters.Add(ADRESSE_P);

                cmd.ExecuteNonQuery();
                textBox_controleur.Text += "Modification de l'activité réussi\n";
            }
            catch
            {
                textBox_controleur.Text += "L'activité n'a pu être modifié\n";
            }
        }

        private void comboBox_activites_SelectedIndexChanged(object sender, EventArgs e)
        {
            OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
            con.Open();
            OracleCommand cmd = new OracleCommand("PACK_ACTIVITE.GET_ACTIVITES_BY_NOM", con);
            cmd.CommandType = CommandType.StoredProcedure;

            OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
            c1.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(c1);

            OracleParameter NOM_P = new OracleParameter("NOM_P", OracleDbType.Varchar2);
            NOM_P.Direction = ParameterDirection.Input;
            NOM_P.Value = comboBox_activites.SelectedItem.ToString();
            cmd.Parameters.Add(NOM_P);

            OracleDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                textBox_unit_temps_activites.Text = "toto";
                textBox_prix_activites.Text = reader["prix_unite"].ToString();
            }
        }

        private void comboBox_nom_emplcament_MouseClick(object sender, MouseEventArgs e)
        {
            if (parcour_emplacement == false)
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_EMPLACEMENT.GET_ALL_EMPLACEMENT", con);
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
                c1.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(c1);

                OracleDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    comboBox_nom_emplcament.Items.Add(reader["num_emplacement"].ToString());
                }
                parcour_emplacement = true;
            }
        }

        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox_nom_emplcament_SelectedIndexChanged(object sender, EventArgs e)
        {
            OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
            con.Open();
            OracleCommand cmd = new OracleCommand("PACK_EMPLACEMENT.GET_EMPLACEMENT_BY_ID", con);
            cmd.CommandType = CommandType.StoredProcedure;

            OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
            c1.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(c1);

            OracleParameter NOM_P = new OracleParameter("NOM_P", OracleDbType.Varchar2);
            NOM_P.Direction = ParameterDirection.Input;
            NOM_P.Value = comboBox_nom_emplcament.SelectedItem.ToString();
            cmd.Parameters.Add(NOM_P);

            OracleDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                textBox_nb_max_estivant.Text = reader["nom"].ToString();
                textBox_type_emplacement.Text = reader["ville"].ToString();
                textBox_descriptif_emplacement.Text = reader["adresse"].ToString();
            }
        }

        private void comboBox1_MouseClick(object sender, MouseEventArgs e)
        {
            if (parcour_emplacement2 == false)
            {
                OracleConnection con = new OracleConnection("user id=tamaris;password=Tamaris1;data source=10.154.126.50:1521/tama");
                con.Open();
                OracleCommand cmd = new OracleCommand("PACK_EMPLACEMENT.GET_ALL_EMPLACEMENT", con);
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter c1 = new OracleParameter("c1", OracleDbType.RefCursor, 50);
                c1.Direction = ParameterDirection.ReturnValue;
                cmd.Parameters.Add(c1);

                OracleDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    comboBox_nom_emplcament.Items.Add(reader["num_emplacement"].ToString());
                }
                parcour_emplacement2 = true;
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
